You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
662 B
31 lines
662 B
import type { RequestHandler } from "@sveltejs/kit";
|
|
|
|
import config from "$lib/config";
|
|
|
|
export const get: RequestHandler = async({params, locals}) => {
|
|
const scopeId = parseInt(params.scope);
|
|
|
|
const db = await config.database();
|
|
const scope = await db.withUser(locals.user.id).scopes().find(scopeId)
|
|
if (scope === null) {
|
|
return {
|
|
status: 404,
|
|
headers: {
|
|
"Content-Type": "application/json"
|
|
},
|
|
body: JSON.stringify({
|
|
message: "Scope not found",
|
|
}),
|
|
}
|
|
}
|
|
|
|
return {
|
|
status: 200,
|
|
headers: {
|
|
"Content-Type": "application/json"
|
|
},
|
|
body: JSON.stringify({
|
|
scope
|
|
}),
|
|
}
|
|
}
|